home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / clib / sys / h / stat < prev    next >
Text File  |  1996-11-09  |  6KB  |  177 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/clib/sys/h/RCS/stat,v $
  4.  * $Date: 1996/10/30 21:58:59 $
  5.  * $Revision: 1.5 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: stat,v $
  10.  * Revision 1.5  1996/10/30 21:58:59  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.4  1996/09/16 21:23:51  unixlib
  14.  * CL_0002 Nick Burret
  15.  * Minor changes to file handling
  16.  * Change most error numbers, and use in assembler sources (SJC)
  17.  * Various minor bug fixes and compatability changes.
  18.  *
  19.  * Revision 1.3  1996/07/21 22:15:12  unixlib
  20.  * CL_0001 Nick Burret
  21.  * Improve memory handling. Remove C++ library incompatibilities.
  22.  * Improve file stat routines.
  23.  *
  24.  * Revision 1.2  1996/05/06 09:01:33  unixlib
  25.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  26.  * Saved for 3.7a release.
  27.  *
  28.  * Revision 1.1  1996/04/19 21:23:56  simon
  29.  * Initial revision
  30.  *
  31.  ***************************************************************************/
  32.  
  33. /* POSIX Standard 5.6: File Characteristics <sys/stat.h>.  */
  34.  
  35. #ifndef __SYS_STAT_H
  36. #define __SYS_STAT_H
  37.  
  38. #ifndef __UNIXLIB_TYPES_H
  39. #include <unixlib/types.h>
  40. #endif
  41. #ifndef __TIME_H
  42. #include <time.h>
  43. #endif
  44.  
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48.  
  49. struct stat
  50.   {
  51.   __dev_t     st_dev; /* Device containing the file.  */
  52.   __ino_t     st_ino; /* File serial number.  */
  53.   __mode_t     st_mode; /* File mode.  */
  54.   __nlink_t    st_nlink; /* Link count.  */
  55.   __uid_t    st_uid; /* User ID of the file's owner.  */
  56.   __gid_t    st_gid; /* Group ID of the file's group. */
  57.   __dev_t     st_rdev; /* Device number, if device.  */
  58.   __off_t     st_size; /* Size of file, in bytes.  */
  59.   time_t    st_atime; /* Time of last access.  */
  60.   unsigned long int st_atime_usec;
  61.   time_t    st_mtime; /* Time of last modification.  */
  62.   unsigned long int st_mtime_usec;
  63.   time_t    st_ctime; /* Time of last status change.  */
  64.   unsigned long int st_ctime_usec;
  65.   unsigned long int st_blksize; /* Optimal block size for I/O.  */
  66. #define _STATBUF_ST_BLKSIZE /* Tell code we have this member. */
  67.   unsigned long int st_nblocks; /* Number of 512-byte blocks allocated.  */
  68.   };
  69.  
  70. /* Bit masks.  */
  71.  
  72. /* Extract the file type code portion of a mode value.  */
  73. #define S_IFMT        0770000
  74.  
  75. /* File type code for a FIFO or pipe.  */
  76. #define S_IFIFO     0010000
  77. #define S_IFPORT    S_IFIFO
  78. /* File type code for a terminal type device file.  */
  79. #define S_IFCHR     0020000
  80. /* File type code for a directory. */
  81. #define S_IFDIR     0040000
  82. /* File type code for a block-oriented device file (disk file).  */
  83. #define S_IFBLK     0100000
  84. /* File type code for a regular file.  */
  85. #define S_IFREG     0200000
  86. /* File type code for a symbolic link.  */
  87. #define S_IFLNK     0400000
  88. /* This is the set-user-ID on execute bit.  */
  89. #define S_ISUID     0004000
  90. /* This is the set-group-ID on execute bit.  */
  91. #define S_ISGID     0002000
  92. /* Socket.  */
  93. #define S_IFSOCK        0140000
  94.  
  95. /* Protection bits.  */
  96.  
  97. /* Save swapped text after use. */
  98. #define S_ISVTX     01000
  99. /* Read by owner.  */
  100. #define S_IREAD         0400
  101. /* Write by owner.  */
  102. #define S_IWRITE    0200
  103. /* Execute by owner.  */
  104. #define S_IEXEC        0100
  105.  
  106. /* Execute (for ordinary files) or search (for directories)
  107.    permission bit for the owner of the file.  */
  108. #define S_IXUSR        S_IEXEC
  109. /* Write permission bit for the owner of the file.  */
  110. #define S_IWUSR            S_IWRITE
  111. /* Read permission bit for the owner of the file.  */
  112. #define S_IRUSR        S_IREAD
  113.  
  114. /* Read, write and execute by owner.  */
  115. #define S_IRWXU (S_IREAD | S_SWRITE | S_IEXEC)
  116.  
  117. #define    S_IRGRP    (S_IRUSR >> 3)    /* Read by group.  */
  118. #define    S_IWGRP    (S_IWUSR >> 3)    /* Write by group.  */
  119. #define    S_IXGRP    (S_IXUSR >> 3)    /* Execute by group.  */
  120. /* Read, write, and execute by group.  */
  121. #define    S_IRWXG    (S_IRWXU >> 3)
  122.  
  123. #define    S_IROTH    (S_IRGRP >> 3)    /* Read by others.  */
  124. #define    S_IWOTH    (S_IWGRP >> 3)    /* Write by others.  */
  125. #define    S_IXOTH    (S_IXGRP >> 3)    /* Execute by others.  */
  126. /* Read, write, and execute by others.  */
  127. #define    S_IRWXO    (S_IRWXG >> 3)
  128.  
  129.  
  130.  
  131. /* Return nonzero if the file is a directory.  */
  132. #define S_ISDIR(x) ((x) & S_IFDIR)
  133. /* Return nonzero if the file is a terminal type device.  */
  134. #define S_ISCHR(x) ((x) & S_IFCHR)
  135. /* Return nonzero if the file is a block special file (like a disk). */
  136. #define S_ISBLK(x) ((x) & S_IFBLK)
  137. /* Return nonzero if the file is a regular file.  */
  138. #define S_ISREG(x) ((x) & S_IFREG)
  139. /* Return nonzero if the file is a FIFO file for pipe.  */
  140. #define S_ISFIFO(x) ((x) & S_IFIFO)
  141. /* Return nonzero if the file is a symbolic link.  */
  142. #define S_ISLNK(x) ((x) & S_IFLNK)
  143. /* Return nonzero if the file is a socket.  */
  144. #define S_ISSOCK(x) ((x) & S_IFSOCK)
  145.  
  146. extern int stat (const char *, struct stat *);
  147. extern int lstat (const char *, struct stat *);
  148. extern int fstat (int, struct stat *);
  149.  
  150. /* Set file access permissions for file to mode.  */
  151. extern int chmod (const char *file, __mode_t mode);
  152.  
  153. /* Set file access permissions of the file fd is open on to mode.  */
  154. extern int fchmod (int fd, __mode_t mode);
  155.  
  156. /* Set the file creation mask of the current process to mask,
  157.    return the old creation mask.  */
  158. extern __mode_t umask (__mode_t mask);
  159.  
  160. /* Create a new directory named path, with permission bits mode.  */
  161. extern int mkdir (const char *path, __mode_t mode);
  162.  
  163. #if 0
  164. /* Create a device file named path, with permission and special bits mode
  165.    and device number dev.  */
  166. extern int mknod (const char *path, __mode_t mode, __dev_t dev);
  167.  
  168. /* Create a new FIFO named path, with permission bits mode.  */
  169. extern int mkfifo (const char *path, __mode_t mode);
  170. #endif
  171.  
  172. #ifdef __cplusplus
  173.     }
  174. #endif
  175.  
  176. #endif
  177.